package com.java.control.impl;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;

import com.java.control.AbstractAdminCommandController;
import com.java.control.search.DeptSearchCond;
import com.java.control.search.SearchStat;
import com.java.entity.Department;
import com.java.service.DeptService;

/**
 * 部门
 * @author wqf
 * @version  Nov 24, 2011 12:28:25 PM
 */
public class DeptListController extends AbstractAdminCommandController {

	public DeptListController(){
		this.setCommandClass(DeptSearchCond.class);
	}
	
	protected ModelAndView executeRequest(HttpServletRequest request,HttpServletResponse response,Object command)
		throws Exception{
		
		DeptSearchCond searchCond = (DeptSearchCond)command;
		
		ModelAndView mav = new ModelAndView(this.view);
		searchCond.setPageSize(10L);
		SearchStat searchStat = this.deptService.getSearchStat(Department.class, searchCond);
		List<Department> list = this.deptService.search(Department.class, searchCond,"id");
		mav.addObject("searchStat", searchStat);
		mav.addObject("searchCond", searchCond);		
		mav.addObject("deptList", list);
		
		return mav;
		
	}

	public void setView(String view) {
		this.view = view;
	}

	public void setDeptService(DeptService deptService) {
		this.deptService = deptService;
	}

	private String view;
	private DeptService deptService;


}
